/**
 * 格式化姓名，使其格式为张**
 * @param {Object} name
 * @param reverse
 */
export function userNameHide(name, reverse = false) {
    if (name != null && typeof name !== 'string') {
        name = name.toString();
    }
    if (!name) {
        return '';
    } else {
        var temp;
        if (name.length >= 1) {
            var nameLeng = name.length;
            if (reverse) {
                if (nameLeng == 2) {
                    name = '*' + name.substring(1, nameLeng);
                } else {
                    name = name.substring(0, 1) + '*' + name.substring(2, nameLeng);
                }
            } else {
                name = name.substring(0, 1);
                for (var i = 0; i < nameLeng; i++) {
                    if (i !== nameLeng - 1) {
                        name += '*';
                    }
                }
            }
            temp = name;
        } else {
            temp = name;
        }
    }
    return temp;
}
